package com.example.springbootwebsocke.controller;


import com.example.springbootwebsocke.pojo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class LoginCotroller {
    @PostMapping("/tologin")
    public Result getLogin(@RequestParam("username")String username, @RequestParam("password") String password, HttpSession httpSession){
      Result result=new Result();
       result.setFlag(true);
       result.setMessage(username);
       httpSession.setAttribute("name",username);

       return result;
    }
    @GetMapping("/fff")
    public Object add(HttpSession session){
        Object name = session.getAttribute("name");
        System.out.println(name);
        return  name;
    }
}
